import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'

import '@/icons' // icon
import '@/permission' // permission control

import axios from 'axios'
axios.defaults.baseURL = store.state.serverResource
axios.defaults.withCredentials = true
Vue.prototype.$axios = axios
// 拦截器
axios.interceptors.response.use(
  response => {
    return response
  },
  error => {
    if (error.response) {
      // switch (error.response.status) {
      //   case 401:
      //     // 返回401 清除用户信息并跳转到登录页面
      //       // 清空登录信息
      //       store.commit('removeUser')
      //       router.replace({
      //         path: '/login',
      //         query: { redirect: router.currentRoute.fullPath }
      //       })
      // }
    }
    console.log(error)
    return Promise.reject(error.response.data)
  }
)

Vue.use(ElementUI)

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
